package cn.itcast.web.controller;

import cn.itcast.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

//抽取公共父类
public class BaseController {

	@Autowired
	protected HttpServletRequest request;

	@Autowired
	protected HttpServletResponse response;

	@Autowired
	protected HttpSession session;


	/**
	 * 获取当前登录用户
	 */
	protected User getLoginUser() {
		return (User) session.getAttribute("loginUser");
	}


	//获取当前登录用户的企业id
	protected String getLoginCompanyId() {
		Object obj = session.getAttribute("loginUser");
		if(obj != null) {
			User user = (User) obj;
			return user.getCompanyId();
		}
		return "" ;
	}

	//获取当前登录用户的企业名称
	protected String getLoginCompanyName() {
		Object obj = session.getAttribute("loginUser");
		if(obj != null) {
			User user = (User) obj;
			return user.getCompanyName();
		}
		return "" ;
	}
}
